import multiprocessing
import time
# 线程池，最多并发三个线程


def task(name):
    print(f"{time.strftime('%H:%M:%S')}:{name}开始执行")
    time.sleep(3)

# 测试
if __name__ == "__main__":
    pool = multiprocessing.Pool(processes=3)
    for i in range(10):
        pool.apply_async(func=task, args=(i,))
    pool.close()
    pool.join()
